//
//  AddressViewController.m
//  HuiPinzhijia
//
//  Created by MS on 16/9/1.
//  Copyright © 2016年 LLMPro. All rights reserved.
//

#import "AddressViewController.h"
#import "NewAddressViewController.h"
@interface AddressViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic, strong)UITableView *myTableView;
@end

@implementation AddressViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    [self.view addSubview:self.myTableView];
    [self createNoAddressView];
    
}

#pragma mark -- 未有地址时的View
- (void)createNoAddressView
{
//    UIView *noThingView = [[UIView alloc]initWithFrame:CGRectMake(0, 64, self.view.frame.size.width, self.view.frame.size.height)];
//    noThingView.backgroundColor = [UIColor whiteColor];
//    [self.view addSubview:noThingView];
//    
//    UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(15, 40, self.view.frame.size.width - 30, 50)];
//    [btn setTitle:@"新增收获地址" forState:UIControlStateNormal];
//    [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
//    btn.backgroundColor = [UIColor blueColor];
//    [btn addTarget:self action:@selector(makeAddressC) forControlEvents:UIControlEventTouchUpInside];
//    [noThingView addSubview:btn];
}

- (UITableView *)myTableView
{
    if (!_myTableView)
    {
        _myTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 64, self.view.frame.size.width, self.view.frame.size.height-96)];
        _myTableView.delegate = self;
        _myTableView.dataSource = self;
        
    }
    
    return _myTableView;
}

#pragma mark -- TableView Delegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 30;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
    if (!cell)
    {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"];
    }
    cell.textLabel.text = @"110";
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForFooterInSection:(NSInteger)section
{
    return 100;
    
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    UIView *noThingView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    noThingView.backgroundColor = [UIColor whiteColor];
//    [self.view addSubview:noThingView];
    
    UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(15, 40, self.view.frame.size.width - 30, 50)];
    [btn setTitle:@"新增收获地址" forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    btn.backgroundColor = [UIColor blueColor];
    [btn addTarget:self action:@selector(makeAddressC) forControlEvents:UIControlEventTouchUpInside];
    [noThingView addSubview:btn];
    
    return noThingView;
}
//新增地址按钮
- (void)makeAddressC
{
    NewAddressViewController *new = [[NewAddressViewController alloc]init];
    [self.navigationController pushViewController:new animated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
